function RadarPing takes nothing returns nothing
	local timer pingTimer = GetExpiredTimer()
	local group allDino = LoadGroupHandle(udg_HT , GetHandleId(pingTimer) , 3)
	local location casterLocation = LoadLocationHandle(udg_HT , GetHandleId(pingTimer) , 4)
	local player casterOwner = LoadPlayerHandle(udg_HT , GetHandleId(pingTimer) , 5)
	local unit whichUnit = FirstOfGroup(allDino)
	local location DinoLocation = GetUnitLoc(whichUnit)
	//--
	call GroupRemoveUnit(allDino , whichUnit)
	if GetUnitState(whichUnit , UNIT_STATE_LIFE) > 0.0 and DistanceBetweenPoints(DinoLocation , casterLocation) < 3000.0 then
		if GetLocalPlayer() == casterOwner then
			call PingMinimap(GetUnitX(whichUnit) , GetUnitY(whichUnit) , 1.0)
		endif
	endif
	call RemoveLocation(DinoLocation)
	set whichUnit = FirstOfGroup(allDino)
	if whichUnit == null then
		call PauseTimer(pingTimer)
		call FlushChildHashtable(udg_HT , GetHandleId(pingTimer))
		call DestroyTimer(pingTimer)
		call DestroyGroup(allDino)
		call RemoveLocation(casterLocation)
	endif
	//--
	set pingTimer = null
	set allDino = null
	set casterLocation = null
	set casterOwner = null
	set whichUnit = null
	set DinoLocation = null
endfunction

function Radar takes nothing returns nothing
	local group allDino = null
	local timer pingTimer = null
	local unit caster = GetTriggerUnit()
	local item battery = GetBattery(caster)
	//--
	call SetItemCharges(battery , GetItemCharges(battery) - 10)
	set allDino = GetUnitsOfPlayerAll(Player(11))
	set pingTimer = CreateTimer()
	call SaveGroupHandle(udg_HT , GetHandleId(pingTimer) , 3 , allDino)
	call SaveLocationHandle(udg_HT , GetHandleId(pingTimer) , 4 , GetUnitLoc(GetTriggerUnit()))
	call SavePlayerHandle(udg_HT , GetHandleId(pingTimer) , 5 , GetOwningPlayer(GetTriggerUnit()))
	call TimerStart(pingTimer , 0.01 , true , function RadarPing)
	//--
	set allDino = null
	set pingTimer = null
	set caster = null
	set battery = null
endfunction

function RadarTry takes nothing returns nothing
	local unit caster = GetTriggerUnit()
	local item battery = GetBattery(caster)
	//--
	if battery == null then
		call PrintP(GetOwningPlayer(caster) , "電力不足")
		call IssueImmediateOrderById(caster , 851972) //停止
	endif
	//--
	set caster = null
	set battery = null
endfunction

function IsRadar takes nothing returns boolean
	return GetSpellAbilityId() == 'A01P'
endfunction

function Trig_Radar_Actions takes nothing returns nothing  
	if IsRadar() then
		call Radar()
	endif
endfunction

function Trig_RadarTry_Actions takes nothing returns nothing
	if IsRadar() then
		call RadarTry()
	endif
endfunction

function InitTrig_Radar takes nothing returns nothing
	local trigger tryTrigger = CreateTrigger()
	//--
	set gg_trg_Radar = CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(tryTrigger, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
	call TriggerAddAction(tryTrigger , function Trig_RadarTry_Actions)
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Radar, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddAction(gg_trg_Radar , function Trig_Radar_Actions)
endfunction